package cn.qp.controller;

import cn.qp.entity.User;
import cn.qp.mapper.UserMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author qipan
 * @date 2020/01/11 16:19
 */
@Controller
public class IndexController {
    @Autowired
    private UserMapper userMapper;

    @RequestMapping("/index")
    @ResponseBody
    public String test() {
        System.out.println("进入test");
        System.out.println("PageNum = 1, pageSize = 1时,userList内容如下");
        PageHelper.startPage(1,1);
        PageInfo<User> userPageInfo = new PageInfo<>(userMapper.selectAll());
        userPageInfo.getList().forEach(System.out::println);
        System.out.println("PageNum = 1, pageSize = 2时,userList内容如下");
        PageHelper.startPage(1,2);
        userPageInfo = new PageInfo<>(userMapper.selectAll());
        userPageInfo.getList().forEach(System.out::println);
        return "hello";
    }

}
